/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2015.07.10                                          *
 * Description:      Region groups that consists of several region       *
 *                                                                       *
 *************************************************************************/

#ifndef FreeMAPs_include_COMMON_regn_Region_h
#define FreeMAPs_include_COMMON_regn_Region_h

#include "FreeMAPsConfig.h"

//COMMON headers
#include "COMMON/base/StateIndicator.h"

#include <set>


namespace FreeMAPs
{

//forward declaration
class SimpleRegion;
/**
 * @brief Region Group is used to describe the region that the equation is defined.
 * each equation will be defined on a Region,
 * it may consist of one or several Region.
 */
class Region : public StateIndicator
{
public:

    Region(
        const std::string& parent_name,
        const std::string& region_name);

    ~Region();

public:

    inline bool
    use_structured_mesh() const;

    inline const std::string&
    get_region_name() const;

    inline bool
    has_simple_region (
        const std::string& simple_region_name) const;

    inline const SimpleRegion*
    get_simple_region(
        const std::string& simple_region_name) const;

    inline const std::map<std::string, SimpleRegion*>&
    get_simple_regions() const;

    inline const std::set<std::string>&
    get_simple_region_names();


public:
    void
    clear();

    void
    check_consistence() const;

    void
    get_from_input (
        const InputDatabase* db);

    friend std::ostream&
    operator << (
        std::ostream& os,
        const Region& rhs);

    bool
    check_all_info_db(const InputDatabase* db);

    void
    add_simple_region(
            const std::string simple_region_name,
            const std::string attr_name);

private:

    typedef StateIndicator Parent;

    bool d_use_structured_mesh;

    /*
     * map<simple_region_name, SimpleRegion*>
     */
    std::map<std::string, SimpleRegion*> d_simple_regions;

    std::set<std::string> d_simple_region_names;

private:

    DISALLOW_COPY_AND_ASSIGN (Region);
};

}

#include "COMMON/regn/Region.inl"

#endif
